<?php
// +----------------------------------------------------------------------
// | Author: 张坤
// +----------------------------------------------------------------------
namespace Admin\Controller; 
class PhoneappointmentController extends AdminController { 
	public function index() {
		$list=M('Phoneappointment')->select();
		//int_to_string($list);
		$this->assign("_list",$list);
		$this->display('index');
	} 
	/**
	 * 保存 
	 */
	public function save() {
		$res = D('Phoneappointment')->update();
		if(!$res){
			$this->error(D('Phoneappointment')->getError());
		}else{
			$this->success('保存成功！', U('Phoneappointment/index'));
		}
	}
	/**
	 * 删除 
	 */
	public function delete($id) {
		$map ['id'] = $id;
		M("Phoneappointment")->where($map)->delete();
		$this->success('操作成功',U('Phoneappointment/index'),false);
	}
	
	/**
	 * 编辑
	 */
	public function edit($id=null){
		empty($id) && $this->error('id不能为空！');
		$data = M('Phoneappointment')->field(true)->find($id);
		$this->assign('data',$data);
		$this->meta_title = '编辑行为';
		$this->display('editaction');
	}
	public function changeStatusSingle($method=null,$id=null){
		$Appointment=D('Phoneappointment');
		$data['id']=$id;
		switch (strtolower($method)){
			case 'callback':
				$data['status']='已回电';
				break;
			case 'nocallback':
				$data['status']='未回电';
				break;
			default:
				$this->error('参数非法');
		}
		$Appointment->save($data);
		$this->success('操作成功',U('Phoneappointment/index'),false);
	}
}
